<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<jsp:include page="../../include/top.jsp"/>
<scrip language="javaScript" type="text/javascript" src="js/My97DatePicker/WdatePicker.js"></scrip>
<div class="main_body">
    <div class="span9 page_message">
        <section id="contents">
            <ul class="tab-nav nav">
                <li><a href="${BasePath}/app/library/list?${PublicParams}">图书列表<span class="arrow fa fa-sort-up"></span></a></li>
                <li class="current"><a href="">图书添加/修改<span class="arrow fa fa-sort-up"></span></a></li>
            </ul>
            <div class="tab-content">
                <div id="tab1" class="tab-pane in tab1">
                    <!-- 表单 -->
                    <form class="form-horizontal" id="myForm" name="myForm" action="${BasePath}/app/library/save" method="post">
                        <input type="hidden" name="id" value="${obj.id }"/>

                        <div class="form-item cf toggle-orderFrom">
                            <label class="item-label">
                                <span class="need_flag">*</span>
                                图书名称：
                                <span class="check-tips"></span>
                            </label>

                            <div class="controls">
                                <input type="text" class="input-xlarge focused" name="name" id="name" value="${obj.name }">
                            </div>
                        </div>
                        <div class="form-item cf toggle-orderFrom">
                            <label class="item-label">
                                <span class="need_flag">*</span>
                                图书作者：
                                <span class="check-tips"></span>
                            </label>

                            <div class="controls">
                                <input type="text" class="input-xlarge focused" name="author" id="author" value="${obj.author }">
                            </div>
                        </div>

                        <div class="form-item cf toggle-orderFrom">
                            <label class="item-label">
                                <span class="need_flag">*</span>
                                出版社：
                                <span class="check-tips"></span>
                            </label>
                            <div class="controls">
                                <input type="text" class="input-xlarge focused" name="press" id="press" value="${obj.press }">
                            </div>
                        </div>
                        <div class="form-item cf toggle-orderFrom">
                            <label class="item-label">
                                <span class="need_flag">*</span>
                               图书类型：
                                <span class="check-tips"></span>
                            </label>
                            <div class="controls">
                                <input type="text" class="input-xlarge focused" name="type" id="type" value="${obj.type}">
                            </div>
                        </div>
                        <div class="form-item cf toggle-startDate">
                            <label class="item-label">
                                <span class="need_flag">*</span>
                                出版日期：
                                <span class="check-tips"></span>
                            </label>
                            <div class="controls">
                                <input type="text" class="Wdate" id="dateText" name="dateText" onfocus="WdatePicker()" value="${obj.date}"/>

                            </div>
                        </div>
                        <div class="form-item cf">
                            <button class="btn submit-btn" id="submit" onclick="checkForm()" type="button">确 定</button>
                        </div>
                    </form>
                </div>
            </div>
        </section>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        setByIdFormatDate("dateText", '${obj.date}');
    });
    function checkForm() {
        var name = $("#name").val();
        if (name.trim() == "") {
            layer.msg('图书名字不能为空!', {icon: 5});
            return false;
        }
        var author = $("#author").val();
        if (author.trim() == "") {
            layer.msg('作者不能为空!', {icon: 5});
            return false;
        }
        var press = $("#press").val();
        if (press.trim() == "") {
            layer.msg('出版社不能为空!', {icon: 5});
            return false;
        }
        var type = $("#type").val();
        if (type.trim() == "") {
            layer.msg('图书类型不能为空!', {icon: 5});
            return false;
        }
        var dateText = $("#dateText").val();
        if (dateText.trim() == "") {
            layer.msg('出版时间不能为空!', {icon: 5});
            return false;
        }

        $('#myForm').ajaxSubmit(function (data) {
            if (data.errno == 1) {
                layer.msg(data.errdesc, {icon: 5});
            } else {
                layer.msg('操作成功！');

                window.location.href = "${BasePath}/app/library/list?${PublicParams}";
            }
        });
    }
</script>
<jsp:include page="../../include/bottom.jsp"/>
